#include <iostream>
using namespace std;
#define maxSize 5
typedef struct queue
{
    int data[maxSize]={-1,-1,-1,-1,-1};
    int front,rear;
}SqQueue;
/*初始化队列*/
void InitQueue(SqQueue &q){
    q.front=q.rear=0;
}
/*判断队列是否为空*/
bool QueueEmpty(SqQueue &q){
    if(q.rear==q.front){
        return true;
    }
    else{
        return false;
    }
}
/*入队*/
bool EnQueue(SqQueue &q,int x){
    if((q.rear+1)%maxSize==q.front){
        return false;//队满，报错
    }
    q.data[q.rear]=x;
    q.rear=(q.rear+1)%maxSize;
    return true;
}
/*出队*/
bool DnQueue(SqQueue &q,int &x){
    if(q.rear==q.front){
        return false;//空队，报错
    }
    x=q.data[q.front];
    q.front=(q.front+1)%maxSize;
    return true;
}
/*取队头元素*/
bool GetHead(SqQueue &q,int &x){
    if(q.front==q.rear){
        return false;//空对，报错
    }
    x=q.data[q.front];
    return true;
}
/*统计队列元素的个数*/
int QueueNum(SqQueue &q){
    int n;
    n=(q.rear-q.front+maxSize)%maxSize;
    return n;
}
int main()
{
    SqQueue t;
    int a[4]={1,2,3,4};
    int b,c,d;
    InitQueue(t);
    for(int i=0;i<4;i++){
        EnQueue(t,a[i]);
    }
    DnQueue(t,c);
    DnQueue(t,c);
    DnQueue(t,c);

    EnQueue(t,5);
    EnQueue(t,6);
    EnQueue(t,7);
    DnQueue(t,c);
    EnQueue(t,8);


}



